#include "main.h"
#include "version.h"

PLUGINLINK*       pluginLink;
HINSTANCE         g_hInstance = NULL;

MM_INTERFACE		mmi;

PLUGININFOEX pluginInfoEx = {
	sizeof( PLUGININFOEX ),
	__PLUGIN_NAME,
	__VERSION_DWORD,
	__DESC,
	__AUTHOR,
	__AUTHOREMAIL,
	__COPYRIGHT,
	__AUTHORWEB,
	UNICODE_AWARE,
	0,
	{0xb529402b, 0x53ba, 0x4c81, { 0x9e, 0x27, 0xd4, 0x31, 0xeb, 0xe8, 0xec, 0x36 }}
};


extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) {
	g_hInstance = hinstDLL;
	return TRUE;
}


extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) {
	return &pluginInfoEx;
}


static const MUUID interfaces[] = {MIID_PROTOCOL, MIID_LAST};


extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) {
	return interfaces;
}


extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) {

	pluginLink = link;
	mir_getMMI(&mmi);

	{	PROTOCOLDESCRIPTOR pd;
		ZeroMemory(&pd, sizeof(pd));
		pd.cbSize = sizeof(pd);
		pd.szName = PROTONAME;
		pd.type = PROTOTYPE_PROTOCOL;
		CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
	}
	CreateServiceFunctions();

	HookEvents();
	GSInit(GS_INIT_WINSOCK);
	GSSetOptInt(GS_OPTION_COLORFILTER, 1);
	LoadOptions();
	options.pszMapOnlineSound = "MapOnline";
	SkinAddNewSoundEx(options.pszMapOnlineSound, PROTONAME, "Map Online");
	return 0;
}


extern "C" int __declspec(dllexport) Unload(void) {
	SaveOptions();
	GSCleanup(GS_INIT_WINSOCK);
	UnhookEvents();
	return 0;
}
